﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JobConfig.aspx.cs" Inherits="TKWeb.Portal.SpiderConfig.JobConfig" ValidateRequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
	<style type="text/css">
		body{font-size:12px;font-family:font-family:"宋体","Arial",\5B8B\4F53,Helvetica,sans-serif;background-color:#fff;}
		
	.GridFrame
{
    margin-top: 5px;
    border-collapse: collapse;
    border-right: #7c9ccf 1px solid;
    border-top: #7c9ccf 1px solid;
    border-left: #7c9ccf 1px solid;
    border-bottom: #7c9ccf 1px solid;
}
.GridItem td ,.GridAlter td
{
    border-right: #999999 1px solid;
    border-top: #999999 1px solid;
    border-left: #999999 1px solid;
    border-bottom: #999999 1px solid;
}
.GridItem
{
    font-family: arial;
    font-size: 9pt;
    background: #f1f1f1;
    padding: 0px 4px 0px 4px;
    height: 14px;
}

.GridEdit
{
    font-family: arial;
    font-size: 9pt;
    background: #ffffff;
    padding: 0px 4px 0px 4px;
    height: 14px;
}

.GridEdit td ,.GridAlter td
{
    border-right: #999999 1px solid;
    border-top: #999999 1px solid;
    border-left: #999999 1px solid;
    border-bottom: #999999 1px solid;
}

.GridHeader
{
    font: bold ;
    font-family: 宋体;
    font-size: 9pt;
    background: #8caae7;
    border-bottom: #7c9ccf 1px solid;
    border-top: #7c9ccf 1px solid;
    border-left: #7c9ccf 1px solid;
    border-right: #7c9ccf 1px solid;
    color: #ffffff;
    text-align:center;
    height:18px;
}
.GridHeader th
{
    font: bold ;
    font-family: 宋体;
    font-size: 9pt;
    background: #8caae7;
    border-bottom: #7c9ccf 1px solid;
    border-top: #7c9ccf 1px solid;
    color: #ffffff;
    text-align:center;
}

.GridAlter
{
    font-family: arial;
    font-size: 9pt;
    background: #f1f1f1;
    padding: 0px 4px 0px 4px;
    height: 14px;
}
	
		.style1
		{
			width: 100%;
		}
		.style3
		{
			width: 67px;
		}
	
	</style>
</head>
<body>
	<div style="width:100%; border-bottom-color:Black; border-bottom-width:1px; border-bottom-style:solid">
		<table style="width:100%;">
			<tr>
				<td>
					<h1 style="font-size:12px; margin:0;"><a href="/" style=" color:Red">推矿网</a></h1></td>
				<td align="right">
					在线客服QQ：<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&amp;uin=2810647042&amp;site=qq&amp;menu=yes">2810647042</a> | 
					<a href="/Passport/Logout.aspx">退出</a>
					</td>
			</tr>
		</table>
	</div>
	<p></p>
	<form id="form1" runat="server">
		<asp:Panel ID="panelGatherSettings" runat="server">
			<div style="padding:3px;">
			任务名称:<asp:TextBox ID="tbJobName" runat="server" Width="120"></asp:TextBox>
			URL种子:<asp:TextBox ID="tbSeedUrls" runat="server" Width="344px"></asp:TextBox>
			速度:<asp:TextBox ID="tbSpeed" runat="server" Width="25" Text="1000"></asp:TextBox>
			编码:<asp:TextBox ID="tbEncoding" runat="server" Width="50" Text="utf-8"></asp:TextBox>
			<asp:Button ID="btnAddJob" runat="server" Text="增加" OnClick="btnAddJob_Click"  />
			</div>
			<asp:GridView ID="gvJob" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="JobId"
				ForeColor="#333333" GridLines="None" OnRowCancelingEdit="gvGatherSettings_RowCancelingEdit"
				OnRowDataBound="gvGatherSettings_RowDataBound" OnRowDeleting="gvGatherSettings_RowDeleting"
				OnRowEditing="gvGatherSettings_RowEditing" OnRowUpdating="gvGatherSettings_RowUpdating" OnRowCommand="gvGatherSettings_RowCommand">
				<RowStyle CssClass="GridItem" />
<EditRowStyle CssClass="GridEdit" />

<SelectedRowStyle CssClass="GridHeader" />

<PagerStyle CssClass="GridItem" />

<HeaderStyle CssClass="GridHeader" />

<FooterStyle CssClass="GridFooter" />

<AlternatingRowStyle CssClass="GridAlter" />
				<Columns>
					<asp:TemplateField HeaderText="任务ID" HeaderStyle-Width="50">
						<ItemTemplate>
							<%# Eval("JobId")%>
						</ItemTemplate>
						<HeaderStyle Width="100px" />
					</asp:TemplateField>
					<asp:TemplateField HeaderText="任务名称" HeaderStyle-Width="150">
						<ItemTemplate>
							<asp:LinkButton ID="LinkButton1" CommandName="show_filerule" runat="server" CommandArgument='<%# Eval("JobId")%>' ><%# Eval("Name")%></asp:LinkButton>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbName" runat="server" Width="130" Text='<%# Eval("Name") %>'></asp:TextBox>
						</EditItemTemplate>
						<HeaderStyle Width="130" />
					</asp:TemplateField>
					<asp:TemplateField HeaderText="URL种子" HeaderStyle-Width="300" >
						<ItemTemplate>
							<%# Eval("Urls") %>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbUrls" runat="server" Width="280" Text='<%# Eval("Urls") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="编码">
						<ItemTemplate>
							<%# Eval("encoding") %>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbEncoding" runat="server" Width="50" Text='<%# Eval("Encoding") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="速度">
						<ItemTemplate>
							<%# Eval("Speed") %>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbSpeed" runat="server" Width="50" Text='<%# Eval("Speed") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="状态">
						<ItemTemplate>
							<%# Eval("StatusString") %>
						</ItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="操作">
						<ItemTemplate>
							<asp:LinkButton ID="lbStart" CommandName="StartJob" runat="server" CommandArgument='<%# Eval("JobId") + "," + Eval("Status")%>' Text='<%# Eval("Status").ToString() == "1" ? "停止" : "启动" %>'></asp:LinkButton>
						</ItemTemplate>
					</asp:TemplateField>
					<asp:CommandField ShowEditButton="True" />
					<asp:CommandField ShowDeleteButton="True" />
				</Columns>
			</asp:GridView>
			<div style=" padding:3px; color:#ee0000">注：多个URL种子用“，”隔开</div>
		</asp:Panel>
		
		
		<asp:Panel ID="panelFileRule" runat="server">
			<div style="padding:3px;">
			<asp:LinkButton ID="lbGotoSettings" runat="server" OnClick="lbGotoSettings_Click"><任务配置列表></asp:LinkButton>
			名称:<asp:TextBox ID="tbFileName" runat="server" Width="100"></asp:TextBox>
			URL规则:<asp:TextBox ID="tbFilePattern" runat="server" Width="240"></asp:TextBox>
			结果接收URL:<asp:TextBox ID="tbFeedRecUrl" runat="server" Width="240"></asp:TextBox>
			Lua脚本:<asp:TextBox ID="tbFileLua" runat="server" Height="46px" TextMode="MultiLine" Width="216px"></asp:TextBox>
			<asp:DropDownList ID="ddIsLoad" runat="server" Visible="false">
				<asp:ListItem Text="是" Value="1" />
				<asp:ListItem Text="否" Value="0" />
			</asp:DropDownList>
			<asp:Button ID="btnAddFileRule" runat="server" Text="增加" OnClick="btnAddFileRule_Click"  />
			</div>
			<asp:GridView ID="gvFileRule" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="FileId"
				ForeColor="#333333" GridLines="None" OnRowCommand="gvFileRule_RowCommand" OnRowDataBound="gvFileRule_RowDataBound" OnRowDeleting="gvFileRule_RowDeleting" OnRowEditing="gvFileRule_RowEditing" OnRowUpdating="gvFileRule_RowUpdating" OnRowCancelingEdit="gvFileRule_RowCancelingEdit">
				<RowStyle CssClass="GridItem" />
<EditRowStyle CssClass="GridEdit" />

<SelectedRowStyle CssClass="GridHeader" />

<PagerStyle CssClass="GridItem" />

<HeaderStyle CssClass="GridHeader" />

<FooterStyle CssClass="GridFooter" />

<AlternatingRowStyle CssClass="GridAlter" />
				
				<Columns>
					<asp:TemplateField HeaderText="文件ID" HeaderStyle-Width="50">
						<ItemTemplate>
							<%# Eval("FileId")%>
						</ItemTemplate>
					</asp:TemplateField>

					<asp:TemplateField HeaderText="名称" HeaderStyle-Width="120">
						<ItemTemplate>
							<asp:LinkButton ID="LinkButton3" CommandName="show_fieldrule" runat="server" CommandArgument='<%# Eval("FileId")%>' ><%# Eval("Name").ToString().Replace("<", "&lt;").Replace(">", "&gt;")%></asp:LinkButton>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbName" runat="server" Width="150" Text='<%# Eval("Name") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>

					<asp:TemplateField HeaderText="文件规则" HeaderStyle-Width="310">
						<ItemTemplate>
							<div style="width:280px; overflow:hidden"><%# Eval("UrlPattern")%></div>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbFilePattern" runat="server" Width="280" Text='<%# Eval("UrlPattern") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>

					<asp:TemplateField HeaderText="结果接收URL" HeaderStyle-Width="310">
						<ItemTemplate>
							<%# Eval("FeedRecUrl")%>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbFeedRecUrl" runat="server" Width="280" Text='<%# Eval("FeedRecUrl") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="Lua脚本" HeaderStyle-Width="200">
						<ItemTemplate>
							<div style="width:280px; overflow:hidden"><%# Eval("Lua").ToString().Replace("<", "&lt;").Replace(">", "&gt;")%></div> 
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbLua" TextMode="MultiLine" Rows="3" runat="server" Width="260" Text='<%# Eval("Lua") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>
					
					<asp:TemplateField HeaderText="是否加载链接" Visible="false">
						<ItemTemplate>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:DropDownList ID="ddIsLoad" runat="server">
								<asp:ListItem Text="是" Value="1" />
								<asp:ListItem Text="否" Value="0" />
							</asp:DropDownList>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:CommandField ShowEditButton="True" />
					<asp:CommandField ShowDeleteButton="True" />
				</Columns>
			</asp:GridView>
		</asp:Panel>
		
		
		<asp:Panel ID="panelFieldRule" runat="server">
			<div style="padding:3px">
			<asp:LinkButton ID="lbGotoFileRule" runat="server" OnClick="lbGotoFileRule_Click"><页面配置列表></asp:LinkButton>
			名称:<asp:TextBox ID="tbFieldName" runat="server" Width="80px"></asp:TextBox>
			字段名:<asp:TextBox ID="tbFieldCode" runat="server" Width="80px"></asp:TextBox>
				数据类型：<asp:DropDownList ID="ddlDataType" runat="server">
				</asp:DropDownList>
				字段长度：<asp:TextBox ID="tbFieldDataLen" runat="server" Width="47px">0</asp:TextBox>
				字段精度：<asp:TextBox ID="tbFieldPreci" runat="server" Width="47px">0</asp:TextBox>
				XPATH:<asp:TextBox ID="tbFieldXPath" runat="server" Width="200px"></asp:TextBox>
			Lua脚本:<asp:TextBox ID="tbFieldLua" runat="server" TextMode="MultiLine" 
					Width="216px"></asp:TextBox>
			<asp:Button ID="btnAddFieldRule" runat="server" Text="增加" OnClick="btnAddFieldRule_Click" />
			</div>
			<asp:GridView ID="gvFieldRule" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="FieldId"
				ForeColor="#333333" GridLines="None" OnRowDataBound="gvFieldRule_RowDataBound" OnRowDeleting="gvFieldRule_RowDeleting" OnRowEditing="gvFieldRule_RowEditing" OnRowUpdating="gvFieldRule_RowUpdating" OnRowCancelingEdit="gvFieldRule_RowCancelingEdit" >
				<RowStyle CssClass="GridItem" />
<EditRowStyle CssClass="GridEdit" />

<SelectedRowStyle CssClass="GridHeader" />

<PagerStyle CssClass="GridItem" />

<HeaderStyle CssClass="GridHeader" />

<FooterStyle CssClass="GridFooter" />

<AlternatingRowStyle CssClass="GridAlter" />
				<Columns>
					<asp:TemplateField HeaderText="字段ID" HeaderStyle-Width="50">
						<ItemTemplate>
							<%# Eval("FieldId")%>
						</ItemTemplate>
						<HeaderStyle Width="100px" />
					</asp:TemplateField>
					<asp:TemplateField HeaderText="名称" HeaderStyle-Width="150">
						<ItemTemplate>
							<%# Eval("Name").ToString().Replace("<", "&lt;").Replace(">", "&gt;")%>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbName" runat="server" Width="100" Text='<%# Eval("Name") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="字段名" HeaderStyle-Width="120">
						<ItemTemplate>
							<%# Eval("Code")%>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbCode" runat="server" Width="100" Text='<%# Eval("Code") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="数据类型" HeaderStyle-Width="80">
						<ItemTemplate>
							<%# GetDataTypeName(Convert.ToInt32(Eval("DataType")))%>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:DropDownList ID="ddlDataType" runat="server"></asp:DropDownList>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="数据长度" HeaderStyle-Width="60">
						<ItemTemplate>
							<%# Eval("DataLen")%>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbDataLen" runat="server" Width="50" Text='<%# Eval("DataLen") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="数据精度" HeaderStyle-Width="60">
						<ItemTemplate>
							<%# Eval("DataPreci")%>
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbDataPreci" runat="server" Width="40" Text='<%# Eval("DataPreci") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>

					<asp:TemplateField HeaderText="XPATH" HeaderStyle-Width="300">
						<ItemTemplate>
							<div style="width:280px; overflow:hidden"><%# Eval("XPath").ToString().Replace("<", "&lt;").Replace(">", "&gt;")%></div> 
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbXPath" runat="server" Width="280" Text='<%# Eval("XPath") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="Lua脚本" HeaderStyle-Width="200">
						<ItemTemplate>
							<div style="width:280px; overflow:hidden"><%# Eval("Lua").ToString().Replace("<", "&lt;").Replace(">", "&gt;")%></div> 
						</ItemTemplate>
						<EditItemTemplate>
							<asp:TextBox ID="tbLua" TextMode="MultiLine" Rows="3" runat="server" Width="260" Text='<%# Eval("Lua") %>'></asp:TextBox>
						</EditItemTemplate>
					</asp:TemplateField>
					<asp:CommandField ShowEditButton="True" />
					<asp:CommandField ShowDeleteButton="True" />
				</Columns>
			</asp:GridView>
			<div style=" padding:3px; color:#ee0000">
			注：<br />
			1.“字段名”即为XML行数据的节点名<br />
			<a href="http://www.w3school.com.cn/xpath/" target="_blank" style="color:#ee0000">2.什么是XPath？</a> <br />
			3.Chrome浏览器下请下载xpathonclick插件， <a href="https://chrome.google.com/webstore/search/xpathonclick" target="_blank">直接下载</a>;Firefox直接使用FirePath。 <br />
			<a href="/Tool/XPath.aspx" target="_blank" style="color:#ee0000">4.在线XPath测试工具</a> <br />
			</div>
			<br /> 
			<div ><br /> 
				<table class="style1">
				<tr>
						<td colspan="2">&nbsp;</td>
					</tr>
					<tr>
						<td align="right">
							测试网址：</td>
						<td>
							<asp:TextBox ID="tbTestUrl" runat="server" Width="512px"></asp:TextBox>
							<asp:Button ID="btnTest" runat="server" Text="测试" OnClick="btnTest_Click" />
						</td>
					</tr>
					<tr>
						<td class="style3" align="right" valign="top">
							测试结果：</td>
						<td>
							<asp:TextBox ID="tbTestResult" runat="server" Rows="20" TextMode="MultiLine" 
								Width="556px"></asp:TextBox>
						</td>
					</tr>
				</table>
			</div>

		</asp:Panel>
	</form>
</body>
</html>
